package com.bao.work;

public class Interface03 {
    public static void main(String[] args) {
        Worker w1=new Worker();
        Worker w2=new Worker();
        w1.pickApple(new CompareBig(),new Apple(5,"红色"),new Apple(9,"绿色"));
        w2.pickApple(new CompareColor(),new Apple(5,"红色"),new Apple(9,"绿色"));
    }
}
class Apple{
    public int size;
    public String color;

    public Apple(int size, String color) {
        this.size = size;
        this.color = color;
    }

    public Apple() {
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "Apple{" +
                "size=" + size +
                ", color='" + color + '\'' +
                '}';
    }
}

interface CompareAble{
    default void compare(Apple a,Apple b){
        System.out.println("挑大的");
        if(a.size>b.size){
            System.out.println(a);
        }else{
            System.out.println(b);
        }
    }
}
class CompareBig implements CompareAble{

}
class CompareColor implements CompareAble{
    @Override
    public void compare(Apple a, Apple b) {
        System.out.println("挑红的");
        if("红色".equals(a.color)){
            System.out.println(a);
        }else if(("红色".equals(b.color))){
            System.out.println(b);
        }
        System.out.println("没有");
    }
}
class Worker {
    public void pickApple(CompareAble c,Apple a1,Apple a2){
        c.compare(a1,a2);
    }
}